/* 
 * Memories Version 1.0
 * Developed by Jigar Desai (http://www.jigar.net/) 
 */
using System;
using System.Collections.Generic;

namespace Memories.Entities
{
	/// <summary>
	/// Folder object
	/// </summary>
	[Serializable()]
	public class Folder : IComparable
	{
		string _Name = "";
		string _FullName = "";
        string _RelativePath = "";

        
		DateTime _CreationTime;
		DateTime _LastAccessTime;
		DateTime _LastWriteTime;
		string _Title = "";
		string _Comment = "";
		string _AuthorizedRoles = "";
		string _AuthorizedEditRoles = "";
        Folder _Parent;

        List<File> _Files = new List<File>();
        List<Folder> _Folders = new List<Folder>();



		/// <summary>
		/// Name of Folder.
		/// </summary>
		public string Name { get { return _Name; } set { _Name = value; } }
		/// <summary>
		/// FullName of Folder gives information about path of Folder.
		/// </summary>
		public string FullName { get { return _FullName; } set { _FullName = value; } }

        
        /// <summary>
        /// Friendly path of Folder.
        /// </summary>
        public string RelativePath { get { return _RelativePath; } set { _RelativePath = value; } }
        
        
        /// <summary>
		/// CreationTime of Folder.
		/// </summary>
        public DateTime CreationTime { get { return _CreationTime; } set { _CreationTime = value; } }
		/// <summary>
		/// LastTime this Folder was accessed.
		/// </summary>
		public DateTime LastAccessTime { get { return _LastAccessTime; } set { _LastAccessTime = value; } }
		/// <summary>
		/// LastTime this Folder was changed.
		/// </summary>
		public DateTime LastWriteTime { get { return _LastWriteTime; } set { _LastWriteTime = value; } }
		/// <summary>
		/// Title of Folder.
		/// </summary>
		public string Title { get { return _Title; } set { _Title = value; } }
		/// <summary>
		/// Comment/Description of Folder. 
		/// </summary>
		public string Comment { get { return _Comment; } set { _Comment = value; } }
		/// <summary>
		/// Roles that can view Folder.
		/// </summary>
		public string AuthorizedRoles { get { return _AuthorizedRoles; } set { _AuthorizedRoles = value; } }
		/// <summary>
		/// Roles that can edit Folder.
		/// </summary>
		public string AuthorizedEditRoles { get { return _AuthorizedEditRoles; } set { _AuthorizedEditRoles = value; } }
		/// <summary>
		/// Collection of Folders (subfolders)
		/// </summary>
        public List<Folder> Folders { get { return _Folders; } set { _Folders = value; } }
        //public Dictionary<string, Folder> Folders { get { return _Folders; } set { _Folders = value; } }
		/// <summary>
		/// Collection of Files.
		/// </summary>
        public List<File> Files { get { return _Files; } set { _Files = value; } }

        /// <summary>
        /// Reference to parent folder.
        /// </summary>
        public Folder Parent { get { return _Parent; } set { _Parent = value; } }
		
		/// <summary>
		/// Constructor 
		/// </summary>
		public Folder() { }

		/// <summary>
        /// Constructor 
		/// </summary>
		/// <param name="info">DirectoryInfo Object</param>
		public Folder(System.IO.DirectoryInfo info)
		{
			_Name = info.Name;
			_FullName = info.FullName;
			_CreationTime = info.CreationTime;
			_LastAccessTime = info.LastAccessTime;
			_LastWriteTime = info.LastWriteTime;
		}

		/// <summary>
		/// Compares using LastWriteTime property.
		/// </summary>
		/// <param name="obj">Object obj</param>
		/// <returns></returns>
		public int CompareTo(object obj) 
		{
			return (int)((this._LastWriteTime.CompareTo(((Folder)obj).LastWriteTime)) * (-1));
		}

	}
}
